﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Nntp
{
    using System.IO;

    using System.Text;

    /// <summary>Represents a HELP command to be sent to an NNTP server, see
    /// <a href="http://www.ietf.org/rfc/rfc3977.txt">RFC 3977</a> 7.2.</summary>
    /// <threadsafety static="true" instance="false"/>
    public sealed class HelpCommand : SingleLineCommand<HelpResponse>
    {
        private static readonly string[] SuccessResponseCodes = { "100" };

        /// <summary>Initializes a new instance of the <see cref="HelpCommand"/> class.</summary>
        public HelpCommand() : base("HELP", 2, SuccessResponseCodes)
        {
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>See <see cref="SingleLineCommandBase{T, U}.CreateResponse"/>.</summary>
        protected sealed override HelpResponse CreateResponse(ResponseStream responseStream)
        {
            using (var reader = new StreamReader(responseStream, Encoding.UTF8))
            {
                return new HelpResponse(reader.ReadToEnd());
            }
        }
    }
}
